//
//  SubTableView.m
//  Test
//
//  Created by apple on 2018/11/9.
//  Copyright © 2018年 apple. All rights reserved.
//

#import "SubTableView.h"

@interface SubTableView ()

@property (nonatomic, strong) UIButton *backBtn;

@end

@implementation SubTableView

- (void)viewDidLoad {
    [super viewDidLoad];
    
//    [self setUpUI];
}

- (void) setUpUI {
    self.tableView.tableHeaderView = self.backBtn;
    self.backBtn.frame = CGRectMake(0, 0, 100, 60);
}


#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 20;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    NSString *cellID = @"cellID";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
    }
    cell.textLabel.text = [NSString stringWithFormat:@"sub %d",(int)indexPath.row];
    
    return cell;
}

#pragma mark - 返回按钮
- (UIButton *)backBtn {
    if (!_backBtn) {
        UIButton *btn = [UIButton new];
        [btn setTitle:@"返回" forState:UIControlStateNormal];
        btn.titleLabel.textAlignment = NSTextAlignmentLeft;
        [btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        _backBtn = btn;
    }
    return _backBtn;
}


@end
